home *** CD-ROM | disk | FTP | other *** search
- Path: news.platinum.com!news
- From: Chris Harris <Chris@harrisoft.mv.com>
- Newsgroups: comp.lang.c++
- Subject: STL An VC++ 4.1
- Date: Thu, 28 Mar 1996 10:47:28 -0500
- Organization: Harrisoft Inc.
- Message-ID: <315AB490.1863@harrisoft.mv.com>
- NNTP-Posting-Host: ns2-ssn.platinum.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (WinNT; I)
-
- I have run into what looks like a problem with the Microsoft
- compiler.
-
- This code sample run fine under Visual Age under OS/2, but under
- Windows NT when compiled with MSVC 4.1 it crashes
- intermittently.
-
- You may have to run it with a parameter of 100 5 times before it
- crashes, but it will crash.
-
- Has anyone else had a similar problem?
-
- Regards,
-
- Chris Harris
-
- Chris@harrisoft.mv.com
-
- ------------------------------------------------
-
- /// begin test.cpp
-
- #define NOMINMAX
- #include <map.h>
- #include <stdio.h>
-
-
- typedef int BOOL;
- typedef unsigned long DWORD;
-
-
- #ifdef _WIN32
- #define _Optlink
- #endif
-
- #ifdef __BORLANDC__
- #define _Optlink
- #endif
-
-
- #include <process.h>
-
-
- DWORD BeginThread(void ( * _Optlink start )( void * ), void*
- Info )
- {
- DWORD dwThread = (DWORD)-1;
- #ifdef _WIN32
- dwThread = _beginthread(start,1024* 20,Info);
- #elif defined __BORLANDC__
- dwThread = _beginthread(start,1024 * 20,Info);
- #else
- dwThread = _beginthread(start,NULL, 1024 * 8,Info);
- #endif
-
- return ( dwThread );
- }
-
- typedef map <int,int*,less<int> > TestMap;
-
- extern "C"
- {
- void RunTest(void*);
- }
-
-
- DWORD dwCount = 0;
- int main(int argc, char** argv )
- {
- if ( 1 == argc )
- {
- printf( "Run with a number parameter" );
- return ( 0 );
- }
-
- for(int i =0; i < atoi(argv[1]); i++)
- {
- BeginThread(RunTest,NULL);
- }
-
- return ( 0 );
- }
-
-
-
- void RunTest(void*)
- {
-
- int* p1;
- int* p2;
- int* p3;
-
- {
- TestMap Map;
-
- p1 = new int ( 1 );
- p2 = new int ( 2 );
- p3 = new int ( 3 );
-
- Map[1] = p1;
- Map[2] = p2;
- Map[3] = p3;
- }
- // Now Map is out of scope
- // so we can delete the integers
- delete p1;
- delete p2;
- delete p3;
-
- }
-